package com.example.mymessagequeue.common;

import lombok.Data;

import java.io.Serializable;

/**
 * 返回请求数据的类
 */
@Data
public class R implements Serializable {

    private Integer code;
    private String msg;
    private Object data;


    public static R success(Integer code, String msg, Object data) {
        R result = new R();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }

    public static R success(Integer code, String msg) {
        R result = new R();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

    public static R success(Object data) {
        R result = new R();
        result.setCode(200);
        result.setData(data);
        return result;
    }
    public static R success(String msg, Object data) {
        R result = new R();
        result.setCode(200);
        result.setData(data);
        result.setMsg(msg);
        return result;
    }

    public static R success(Integer code, Object data) {
        R result = new R();
        result.setCode(code);
        result.setData(data);
        return result;
    }

    public static R success(String msg) {
        R result = new R();
        result.setCode(200);
        result.setMsg(msg);
        return result;
    }
    public static R success() {
        R result = new R();
        result.setCode(200);
        return result;
    }

    public static R error(Integer code, String msg, Object data) {
        R result = new R();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }

    public static R error(String msg, Object data) {
        R result = new R();
        result.setCode(500);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }

    public static R error(Integer code, String msg) {
        R result = new R();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

    public static R error(Object data) {
        R result = new R();
        result.setCode(500);
        result.setData(data);
        return result;
    }

    public static R error(String msg) {
        R result = new R();
        result.setCode(500);
        result.setMsg(msg);
        return result;
    }
    public static R error() {
        R result = new R();
        result.setCode(500);
        return result;
    }
}